import os

import datetime

from demo import config
from demo.long_video_demo import run
from demo.m3u8_test2 import download

if __name__ == '__main__':
    url = config.url

    prefix, appendix = os.path.splitext(url.split('/')[-1])
    file_name = f'{prefix}.mp4'
    # 获得download文件夹
    download_path = os.getcwd() + "/download"
    if not os.path.exists(download_path):
        os.mkdir(download_path)

    # 新建日期文件夹
    download_path = os.path.join(download_path, datetime.datetime.now().strftime('%Y%m%d_%H%M%S'))
    os.mkdir(download_path)

    # 下载视频
    download(url, download_path, file_name)

    # 下载得到的视频地址
    video_path = f'{download_path}/{file_name}'

    # 执行预测程序
    run(video_path, download_path)
